<?php
class Ecard_model extends CI_Model{
	public function __construct(){
		$this->load->database();
	}
	
	//所有素材
	public function lists($data){
		$query = $this->db->get_where('ecard',$data);
		return $query->result_array();
	}
	
	//模板信息
	public function getEcardInfo($id){
		$query = $this->db->get_where('ecard',array('id'=>$id));
		return $query->row_array();
	}
	
	//添加用户个人名片
	public function addUserEcard($uid,$url){
	
		$this->db->insert('user_ecard',array('uid'=>$uid,'url'=>$url));
		return $this->db->insert_id();
	}
	
	//更新名片
	public function updateEcard($data,$where){
		return $this->db->update('user_ecard',$data,$where);
	}
	
	//用户名片信息
	public function userEcardInfo($id){
		$query = $this->db->get_where('user_ecard',array('id'=>$id));
		return $query->row_array();
	}
	
	//用户所有名片
	public function userEcard($userid){
		$query = $this->db->get_where("user_ecard",array('uid'=>$userid));
		return $query->result_array();
	}
	
}
?>